package com.hb.medical_research_system.common;

import com.hb.medical_research_system.entity.User;

public class UserThreadLocal {
    //单例
    private UserThreadLocal(){}

    private static final ThreadLocal<User> userThreadLocal= new ThreadLocal<>();

    /**
     * 创建本地线程
     * @param user
     */
    public static void put(User user){
        userThreadLocal.set(user);
    }

    /**
     * 获得本地线程
     * @return
     */
    public static User get(){
        return userThreadLocal.get();
    }

    /**
     * 关闭本地线程
     */
    public static void remove(){
        userThreadLocal.remove();
    }
}
